/*
 * =====================================================================================
 *
 *       Filename:  led_on.c
 *
 *    Description:  点亮GPF4
 *
 *        Version:  1.0
 *        Created:  2018年10月29日 17时15分18秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */

/*
 * 为什么要用unsigned long，而不是unsigned int?
 */
#define GPFCON (*(volatile unsigned long*)0x56000050)
#define GPFDAT (*(volatile unsigned long*)0x56000054)

#define GPFCON_MASK(num) (3<<(num<<1))
#define GPFCON_OUT(num)  (1<<(num<<1))
#define GPFDAT_HIGH(num) (1<<num)

int main(int argc, char **argv)
{
    GPFCON &= ~(GPFCON_MASK(4));  /* GPF[9:8]置0 */
    GPFCON |= GPFCON_OUT(4);      /* GPF4设置OUT */

    GPFDAT |= GPFDAT_HIGH(4);     /* GPF4设置高电平 */
    GPFDAT &= ~GPFDAT_HIGH(4);    /* GPF4设置低电平 */
    return 0;
}
